import asyncio
import neo4j
from neo4j import AsyncGraphDatabase, RoutingControl

uri = "neo4j://localhost:7687"
driver = AsyncGraphDatabase.driver(uri, auth=("neo4j", "12345678"))

from typing import List

import neo4j

async def example(driver: neo4j.AsyncDriver) -> List[str]:
    """Get the name of all 42 year-olds."""
    records, summary, keys = await driver.execute_query(
        "MATCH(a:Person) WHERE a.name = $name RETURN a.name",
        {"name": 'alice'},
        routing_=neo4j.RoutingControl.READ,  # or just "r"
        database_="neo4j",
    )
    return [str(record["a.name"]) for record in records]
    # or: return [str(record[0]) for record in records]
    # or even: return list(map(lambda r: str(r[0]), records))

loop = asyncio.new_event_loop()
task = loop.create_task(example(driver))
result = loop.run_until_complete(task)
# 关闭连接
loop.run_until_complete(driver.close())
# 打印结果
print(result)